package net.zjitc.servlet;

import net.zjitc.dao.impl.ProductDaoImpl;
import net.zjitc.domain.Product;
import net.zjitc.service.ProductService;
import net.zjitc.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @Author admin
 * @Date 2019/2/25 11:19
 */
@WebServlet(name = "findAll" , urlPatterns = "/findAll")
public class AServlet extends HttpServlet {
    ProductServiceImpl service = new ProductServiceImpl();
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ProductDaoImpl productDao=new ProductDaoImpl();
        List<Product> list= null;
        try {
            list = productDao.findAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        request.setAttribute("list",list);
        request.getRequestDispatcher("/WEB-INF/findAll.jsp").forward(request,response);
    }
}
